<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>

<!--[if IEMobile 7]><html class="no-js iem7 oldie"><![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js ie7 oldie" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js ie8 oldie" lang="en"><![endif]-->
<!--[if (IE 9)&!(IEMobile)]><html class="no-js ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|(gt IEMobile 7)]><!--><html class="no-js" lang="en"><!--<![endif]-->

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<title>文化创意产业项目虚拟仿真实验教学系统</title>
	<%@include file="/header.jsp" %>
	<script type="text/javascript" src="/js/init.js"></script>
	<script type="text/javascript">
		var pageNumber;
		$(function() {
			var type = "${sessionScope.currentUser.type}";
			if(type==0) 
				activeMenu(13);
			else if(type==1)
				activeMenu(4);
		})
		
		function turnpage(pageNo) {
			if(pageNo==null)
				pageNo = 1;
			pageNumber = pageNo;
			$("#project-table-div").load("/project/turnpage", {
				pageNo:pageNo,
			})
		}
		
		function queryProject() {
			turnpage(pageNumber);
		}
		
		function addProject(id) {
			var modal = $.modal({
				title: "新建项目",
				url: '/project/add/'+id,
				width: 500,
				ajax: {
					success: function()
					{
						modal.centerModal();
					}
				},
				buttons: {
					'保存': {
						classes: 'small blue-gradient glossy center',
						click: function(win){
							$.ajax({
								url:"/project/check",
								type:"post",
								data:"name="+$("#project-form").find("input[name='project.name']").val(),
								dataType:"json",
								async:false
							}).done(function(data) {
								if(data.isSuccess) {
									$.ajax({
										url:"/project/save",
										type:"post",
										data:$("#project-form").serialize(),
										dataType:"json"
									}).done(function(data){
										myalert(data.msg, function() {
											if(data.isSuccess) {
												win.closeModal();
											}
										});
									})
								} else {
									myalert(data.msg);
								}
							})
						}
					},
					'关闭': {
						classes: 'small blue-gradient glossy center',
						click: function(win) { win.closeModal(); }
					}
				}
			});
		}
		
		function proAudit(id) {
			var modal = $.modal({
				title: "项目审核",
				content:'<p>'+
						'	<input type="radio" name="flag" id="radio-1" value="1" onclick="taudit(1)"><label for="radio-1" class="label">通过</label>'+
						'	<input type="radio" name="flag" id="radio-2" value="0" onclick="taudit(0)"><label for="radio-2" class="label">不通过</label><p/>'+
						'	<textarea id="errortext" name="error" style="display:none;"'+
						'    class="input full-width autoexpanding" ></textarea>'+
						'</p>'
						,
				width: 500,
				ajax: {
					success: function()
					{
						modal.centerModal();
					}
				},
				buttons: {
					'提交': {
						classes: 'small blue-gradient glossy center',
						click: function(win){
							var isPassed = $("input[name='flag']:checked").val();
							var errorText = $("#errortext").val();
							$.ajax({
								url:"/project/audit",
								type:"post",
								data:{
									isPassed:isPassed,
									projectId:id,
									errorText:errorText
								},
								dataType:"json"
							}).done(function(data){
								myalert(data.msg, function() {
									if(data.isSuccess) {
										win.closeModal();
										queryProject();
									}
								});
							})
						}
					},
					'关闭': {
						classes: 'small blue-gradient glossy center',
						click: function(win) { win.closeModal(); }
					}
				}
			})
		}
		
		function taudit(flag){
			if(flag==1){
				$("#errortext").hide();
				$("#errortext").val("");
			}else if(flag==0){
				$("#errortext").show();
			}
		}
		
		function teamAudit(id) {
			var modal = $.modal({
				title: "团队审核",
				url:"/project/teamView/"+id,
				width: 600,
				ajax: {
					success: function()
					{
						modal.centerModal();
					}
				},
				buttons: {
					'提交': {
						classes: 'small blue-gradient glossy center',
						click: function(win){
							var isPassed = $("input[name='flag']:checked").val();
							if(isPassed==null)
								myalert("请给出审核结果！！");
							else {
								$.ajax({
									url:"/project/teamAudit",
									type:"post",
									data:{
										isPassed:isPassed,
										projectId:id,
									},
									dataType:"json"
								}).done(function(data){
									myalert(data.msg, function() {
										if(data.isSuccess) {
											win.closeModal();
											queryProject();
										}
									});
								})
							}
						}
					},
					'关闭': {
						classes: 'small blue-gradient glossy center',
						click: function(win) { win.closeModal(); }
					}
				}
			})
		}
		
		function processView(projectId) {
			var modal = $.modal({
				title: "流程图",
				url:"/task/processView?projectId="+projectId,
				width: 700,
				height:500,
				//useIframe: true,
				ajax: {
					success: function()
					{
						modal.centerModal();
					}
				},
				buttons: {
					'关闭': {
						classes: 'small blue-gradient glossy center',
						click: function(win){
							win.closeModal();
						}
					}
				}
			})
		}
		
		function delProject(id, status) {
			if(status==6) {
				myalert("进行中的项目不能删除！！");
				return;
			}
			myconfirm("确定删除？", function() {
				$.ajax({
					url:"/project/del/"+id,
					dataType:"json"
				}).done(function(data){
					myalert(data.msg, function() {
						if(data.isSuccess)
							window.location = window.location;
					})
				})
			})
		}
	</script>
</head>

<body class="clearfix with-menu with-shortcuts">

	<!-- Prompt IE 6 users to install Chrome Frame -->
	<!--[if lt IE 7]><p class="message red-gradient simpler">Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->

	<!-- Title bar -->
	<header role="banner" id="title-bar">
		<h2>文化创意产业项目虚拟仿真实验教学系统</h2>
	</header>

	<!-- Button to open/hide menu -->
	<a href="#" id="open-menu"><span>Menu</span></a>

	<!-- Button to open/hide shortcuts -->
	<a href="#" id="open-shortcuts"><span class="icon-thumbs"></span></a>

	<!-- Main content -->
	<section role="main" id="main">

		<noscript class="message black-gradient simpler">Your browser does not support JavaScript! Some features won't work as expected...</noscript>

		<hgroup id="main-title" class="thin">
			<h1>项目列表</h1>
		</hgroup>

		<div class="with-padding">
			<div>
				<div class="dataTables_header">
					<div id="sorting-advanced_length" class="dataTables_length">
						<p/>
					</div>
				</div>
				<div id="project-table-div">
					<jsp:include page="project_table.jsp"/>
				</div>
			</div>
		</div>
	</section>
	<!-- End main content -->

	<script>

		// Call template init (optional, but faster if called manually)
		$.template.init();
		
	</script>
</body>
</html>